<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>注册</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<link rel="stylesheet" href="../AmazeUI-2.4.2/assets/css/amazeui.min.css" />
		<link href="../css/dlstyle.css" rel="stylesheet" type="text/css">
		<script src="../AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="../AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>

		<script type="text/javascript" src="./plugins/vue/dist/vue.min.js"></script>

		<script type="text/javascript" src="./plugins/axios/dist/axios.min.js"></script>

		<script type="text/javascript" src="./plugins/vue/common.js"></script>

	</head>

	<body>

		<div class="login-boxtitle">
			<a href="home/demo.html"><img alt="" src="../images/logobig.png" /></a>
		</div>

		<div class="res-banner" id="app">
			<div class="res-main">
				<div class="login-banner-bg"><span></span><img src="../images/big.jpg" /></div>
				<div class="login-box">

						<div class="am-tabs" id="doc-my-tabs">
							<ul class="am-tabs-nav am-nav am-nav-tabs am-nav-justify">
								<li><a href="">手机号注册</a></li>
							</ul>

							<div class="am-tabs-bd">

								<!--被注册提示信息-->
								<span id="check" style="color:#ff0000;"></span>
								<div class="am-tab-panel">
									<form method="post">
                 <div class="user-phone" v-model="phoneCodeForm">
								    <label for="phone"><i class="am-icon-mobile-phone am-icon-md"></i></label>
								    <input type="tel" name="" id="phone" v-model="phoneCodeForm.phone" placeholder="请输入手机号">
                 </div>																			
										<div class="verification">
											<label for="code"><i class="am-icon-code-fork"></i></label>
											<input type="tel" name="" id="code" v-model="phoneCodeForm.code" placeholder="请输入验证码">
											<button type="button" id="sendMobileCode" v-bind:disabled="disabled"   class="btn" @click="sendMobileCode">获取</button>

										</div>
									</form>
								
										<div class="am-cf">
											<input type="button" name=""  @click="loginCode" value="登录" class="am-btn am-btn-primary am-btn-sm am-fl">
										</div>
								
									<hr>
								</div>

								<script>
									$(function() {
									    $('#doc-my-tabs').tabs();
									  })
								</script>

							</div>
						</div>

				</div>
			</div>
			
					<div class="footer ">
						<div class="footer-hd ">
							<p>
								<a href="# ">恒望科技</a>
								<b>|</b>
								<a href="# ">商城首页</a>
								<b>|</b>
								<a href="# ">支付宝</a>
								<b>|</b>
								<a href="# ">物流</a>
							</p>
						</div>
						<div class="footer-bd ">
							<p>
								<a href="# ">关于恒望</a>
								<a href="# ">合作伙伴</a>
								<a href="# ">联系我们</a>
								<a href="# ">网站地图</a>
								<em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a> - Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></em>
							</p>
						</div>
					</div>
		</div>
	</body>

<script type="text/javascript">
	new Vue({
		el:"#app",
		data:{
			//是否禁用，默认false不禁用
			disabled: false,
			//手机号注册表单
			phoneCodeForm:{
				phone:"",
				code:""
			}
		},
		methods: {
			loginCode(){
				if (!this.phoneCodeForm.phone){
					alert("手机号不能为空！")
					return;
				}
				if (!this.phoneCodeForm.code){
					alert("验证码不能为空！")
					return;
				}
					//获取表单
					let para = Object.assign({}, this.phoneCodeForm); //shop 本身这个参数里面就有店铺和管理员信息
					//发送请求去后台进行登录
					this.$http.put("/user/loginByCode", para).then((res => {
						//解构表达式接收
						let {msg, success, result} = res.data;
						//提示信息
						$("#check").html(res.data.msg);
						if (res.data.success){
							window.location.href = "http://www.360msj.xyz/index.html";
							localStorage.removeItem("token");
							localStorage.removeItem("loginUser");
							//将令牌存储到本地
							let token = localStorage.setItem("token", result.token);
							//将对象json字符串存放到本地
							let loginUser = localStorage.setItem("loginUser", JSON.stringify(result.loginUser));//将对象转化为json字符串
						}
					}));
			},
			//发送验证码
			sendMobileCode() {
					//获取手机号
					let param = {"phone": this.phoneCodeForm.phone};
					//发送ajax请求获取验证码
					this.$http.post("/code/verificationPhoneCode", param).then((res => {
						//发送请求的时候获取按钮为禁用状态
						this.disabled = true;
						//设置倒计时时间
						let timer = 60;
						//直接显示时间
						$("#sendMobileCode").html(timer);
						let that = this;
						//设置计算器为60秒,一秒减一次
						let interval = setInterval(function () {
							//计算器时间自减
							timer--;
							//倒计时显示
							$("#sendMobileCode").html(timer);

							//当计算器时间为0的时候
							if (timer == 0) {
								//设置按钮为重发
								$("#sendMobileCode").html("重发");
								//清除计数器
								clearInterval(interval);
								//可以进行点击
								that.disabled = false;
							}

						}, 1000);
						//提示信息
						if(res.data.msg !=null){
							//提示信息
							$("#check").html(res.data.msg);
						}

					}));
					$("#check").html("");
			}
		},
		//监听数据
		watch: {
			"phoneCodeForm.phone":function(newVel,oldVel){
				//获取手机号
				let param = {"phone": this.phoneCodeForm.phone};
				//发送ajax请求验证手机号是否被注册
				this.$http.post("/user/checkPhone", param).then((res => {
					//提示信息
					$("#check").html(res.data.msg);
				}));
			}
		}

	});


</script>

</html>